﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.InteropServices;
using System.Collections;

namespace Liquifier
{
    public partial class Liquifer
    {
        protected void CollectTypeMembers(Type t, bool filter)
        {
            LiquifiableAttribute settings = serializeablesEquivalentSettings;   //if the user hasn't marked Liquifiable, well give it a go with default settings...

            object[] attributes = t.GetCustomAttributes(typeof(LiquifiableAttribute), true);
            if (attributes.Length > 0)
            {
                settings = attributes[0] as LiquifiableAttribute;
            }

            if (settings == null)
            {
                throw new Exception(string.Format("Type '{0}' is not marked liquifiable.", TargetType.ToString()));
            }

            TargetType.CollectMembers();

            if (filter)
            {
                LocalMembers = TargetType.FilterMembers(settings).Copy();
            }
            else
            {
                LocalMembers = TargetType.Members.Copy();
            }

        }
    }

}
